<?php
/**
 * Created by PhpStorm.
 * User: root
 * Date: 10/15/14
 * Time: 8:09 AM
 */

namespace Common\Models\Videos;


class HomeVideo extends \Phalcon\Mvc\Model
{
    protected $id;

    protected $home_category_id;

    protected $object_id;

    protected $object_type;

    protected $position;

    protected $status;


    public function getSource()
    {
        return 'home_video';
    }

    public function initialize(){
        $this->belongsTo('object_id','Common\Models\Videos\Video','id',array(
            'alias'     =>  'video'
        ));

        $this->belongsTo('object_id','Common\Models\Videos\VideoGroup','id',array(
            'alias'     =>  'videoGroup'
        ));
    }

    public function afterDelete()
    {
        $this->clearCache();
    }

    public function afterSave()
    {
        $this->clearCache();   
    }
    public function clearCache()
    {
        if ($this->id) {
            $viewCache = $this->getDI()->getViewCache();
            $viewCache->delete($this->constant->keyCache['homeCategory']['blockVideoCategory'] . '-' . $this->home_category_id);            
        }
    }
    /**
     * @param mixed $home_category_id
     */
    public function setHomeCategoryId($home_category_id)
    {
        $this->home_category_id = $home_category_id;
    }

    /**
     * @return mixed
     */
    public function getHomeCategoryId()
    {
        return $this->home_category_id;
    }

    /**
     * @param mixed $id
     */
    public function setId($id)
    {
        $this->id = $id;
    }

    /**
     * @return mixed
     */
    public function getId()
    {
        return $this->id;
    }

    /**
     * @param mixed $object_id
     */
    public function setObjectId($object_id)
    {
        $this->object_id = $object_id;
    }

    /**
     * @return mixed
     */
    public function getObjectId()
    {
        return $this->object_id;
    }

    /**
     * @param mixed $position
     */
    public function setPosition($position)
    {
        $this->position = $position;
    }

    /**
     * @return mixed
     */
    public function getPosition()
    {
        return $this->position;
    }

    /**
     * @param mixed $object_type
     */
    public function setObjectType($object_type)
    {
        $this->object_type = $object_type;
    }

    /**
     * @return mixed
     */
    public function getObjectType()
    {
        return $this->object_type;
    }

    /**
     * @param mixed $status
     */
    public function setStatus($status)
    {
        $this->status = $status;
    }

    /**
     * @return mixed
     */
    public function getStatus()
    {
        return $this->status;
    }


} 